Skip to content

Conversation

@Ecarrion
Copy link
Contributor

@Ecarrion Ecarrion commented Jan 3, 2023

closes: #8488

Why

This PR adds a ProductVariationGenerator type that is in charge to generate all possible variations from product attributes. Additionally, it excludes any provided existing variation from the combination list.

How

  • Adds a ProductVariationGenerator type that creates all possible variations. Internally it uses the cartesian product algorithm to generate combinations. Mainly copied from our android counterpart.

  • Integrates the generator on ProductVariationsViewModel, and outputs the number of variations to generate in the console. Variation creation will be shipped on a different PR.

Testing Steps


  • Go to a variable product with all of it's variations
  • Delete some variations
  • Tap the "Generate All Variations" CTA
  • See in the console that the correct number of variations is outputted.

  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@Ecarrion Ecarrion added the feature: variation list Related to the variations list for variable products. label Jan 3, 2023
@Ecarrion Ecarrion added this to the 11.8 milestone Jan 3, 2023
@Ecarrion Ecarrion requested a review from ealeksandrov January 3, 2023 17:21
@wpmobilebot
Copy link
Collaborator

You can test the changes from this Pull Request by:
  • Clicking here or scanning the QR code below to access App Center
  • Then installing the build number pr8537-946d30f on your iPhone

If you need access to App Center, please ask a maintainer to add you.

Copy link
Contributor

@ealeksandrov ealeksandrov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works well! :shipit:

I've noticed one visual nit that may disappear in further development: when action is triggered, whole variation list blinks with empty state (no existing variations, no "•••" button) before reappearing again. It's very quick transition, but I can always reproduce it.

ProductVariationAttribute(id: option.attributeID, name: option.attributeName, option: option.value)
}
// Setting a regular price is not required when creating a variation.
return CreateProductVariation(regularPrice: "", attributes: attributes)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: updating initializer to have empty string as a default value for regularPrice can improve readability.

@Ecarrion
Copy link
Contributor Author

Ecarrion commented Jan 4, 2023

I've noticed one visual nit that may disappear in further development: when action is triggered, whole variation list blinks with empty state (no existing variations, no "•••" button) before reappearing again. It's very quick transition, but I can always reproduce it.

Nice catch, this happens because when resyncing variations the current ones are deleted. I'll make sure to handle this!

@Ecarrion Ecarrion merged commit 77ff590 into trunk Jan 4, 2023
@Ecarrion Ecarrion deleted the issue/8488-product-variation-generator branch January 4, 2023 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature: variation list Related to the variations list for variable products.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Variations: Generate All Variations Locally

4 participants